program numbertwo;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  x1, y1, x2, y2, x3, y3, x4, y4, a1, b1, c1, a2, b2, c2: integer;
  xp, yp, d1, d2: real;

begin
  readln(x1, y1, x2, y2, x3, y3, x4, y4);
  a1:=y1-y2;
  b1:=x2-x1;
  c1:=x1*y2-x2*y1;
  c2:=x3*y4-x4*y3;
  b2:=x4-x3;
  a2:=y3-y4;
if (a1<>0) and (a2*b1<>a1*b2) then
begin
  yp:=(a1*c2-a2*c1)/(a2*b1-a1*b2);
  xp:=(-(c1+b1*yp))/a1;
if (((x2-x1)*(xp-x1))>=0) and (((y2-y1)*(yp-y1))>=0) and(((x4-x3)*(xp-x3))>=0) and (((y4-y3)*(yp-y3))>=0) then
  write('0')
else
begin
  d1:=(a1*x3+b1*y3+c1)/(sqrt(a1*a1+b1*b1));
  d2:=(a2*x1+b2*y1+c2)/(sqrt(a2*a2+b2*b2));
if (d1>d2) then
  write(abs(d2))//:0:3)
else
  write(abs(d1));//:0:3);
end;

end
else
  write(abs(((a1*x3+b1*y3+c1)/(sqrt(a1*a1+b1*b1)))):0:3);
  readln;
end.
